namespace GarageManagement.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AddVehicleTable : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.Vehicle",
                c => new
                    {
                        VehicleId = c.Int(nullable: false, identity: true),
                        Registration = c.String(nullable: false, maxLength: 10),
                        Model = c.String(maxLength: 255),
                        Year = c.Int(nullable: false),
                        Color = c.String(maxLength: 25),
                        EngineSize = c.String(maxLength: 25),
                        Doors = c.Int(nullable: false),
                        Fuel = c.String(maxLength: 255),
                        GearboxType = c.String(maxLength: 255),
                        Gears = c.Int(nullable: false),
                        EngineNumber = c.String(maxLength: 255),
                        CylinderArrangement = c.String(maxLength: 255),
                        Cylinders = c.Int(nullable: false),
                        Bore = c.Double(nullable: false),
                        Valves = c.String(maxLength: 255),
                        ValveGear = c.String(maxLength: 255),
                        Height = c.Double(nullable: false),
                        Width = c.Double(nullable: false),
                        Length = c.Double(nullable: false),
                        ManufacturerId = c.Int(nullable: false),
                        CustomerId = c.Int(nullable: false),
                    })
                .PrimaryKey(t => t.VehicleId)
                .ForeignKey("dbo.Manufacturer", t => t.ManufacturerId, cascadeDelete: true)
                .ForeignKey("dbo.Customer", t => t.CustomerId, cascadeDelete: true)
                .Index(t => t.ManufacturerId)
                .Index(t => t.CustomerId);
            Sql("CREATE UNIQUE INDEX IX_Vehicle_Registration ON Vehicle (Registration)");
        }
        
        public override void Down()
        {
            DropIndex("dbo.Vehicle", new[] { "CustomerId" });
            DropIndex("dbo.Vehicle", new[] { "ManufacturerId" });
            DropForeignKey("dbo.Vehicle", "CustomerId", "dbo.Customer");
            DropForeignKey("dbo.Vehicle", "ManufacturerId", "dbo.Manufacturer");
            DropTable("dbo.Vehicle");
        }
    }
}
